package com.chuangsi.project.admin.dto.admin.order;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.annotation.write.style.HeadStyle;
import com.chuangsi.common.config.excel.LocalDateConverter;
import com.chuangsi.common.config.excel.LocalDateTimeConverter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.poi.ss.usermodel.HorizontalAlignment;

import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * @author wangshengming
 * @date 2023/3/27
 */
@Data
@HeadStyle(horizontalAlignment = HorizontalAlignment.CENTER)
@ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER)
@ColumnWidth(20)
public class ResFinanceOrderPageDto {

    @ApiModelProperty(value = "订单id")
    @ExcelIgnore
    private String orderId;

    @ApiModelProperty(value = "印章名称")
    @ExcelProperty(value = "印章名称")
    @ColumnWidth(30)
    private String sealName;

    @ApiModelProperty(value = "客户名称")
    @ExcelProperty(value = "客户名称")
    private String customName;

    @ApiModelProperty(value = "客户联系方式")
    @ExcelProperty(value = "客户联系方式")
    private String customPhone;

    @ApiModelProperty(value = "客户身份证号")
    @ExcelProperty(value = "客户身份证号")
    private String customIdCard;

    @ApiModelProperty(value = "订单金额")
    @ExcelProperty(value = "订单金额")
    private BigDecimal money;

    @ApiModelProperty(value = "订单时间")
    @ExcelProperty(value = "订单时间",converter = LocalDateTimeConverter.class)
    @ColumnWidth(30)
    @ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER, dataFormat = 49)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "开票状态")
    @ExcelProperty(value = "开票状态")
    private String invoiceStatus;

    @ApiModelProperty(value = "开票时间")
    @ExcelProperty(value = "开票时间",converter = LocalDateConverter.class)
    @ContentStyle(horizontalAlignment = HorizontalAlignment.CENTER, dataFormat = 49)
    private LocalDate invoiceDate;

    @ApiModelProperty(value = "发票-抬头")
    @ExcelProperty(value = "抬头")
    private String invoiceHeader;

    @ApiModelProperty(value = "发票-税号")
    @ExcelProperty(value = "税号")
    private String socialCreditCode;

    @ApiModelProperty(value = "发票-开户银行")
    @ExcelProperty(value = "开户银行")
    private String openingBank;

    @ApiModelProperty(value = "银行账号")
    @ExcelProperty(value = "银行账号")
    private String accountNumber;

    @ApiModelProperty(value = "电话")
    @ExcelProperty(value = "电话")
    private String phone;

    @ApiModelProperty(value = "地址")
    @ExcelProperty(value = "地址")
    private String address;

    @ApiModelProperty(value = "发票备注")
    @ExcelProperty(value = "发票备注")
    private String invoiceRemark;

    @ApiModelProperty(value = "发票链接")
    @ExcelIgnore
    private String invoiceUris;

    public String getInvoiceStatus() {
        if(StrUtil.isNotBlank(invoiceStatus)){
            if(invoiceStatus.equals("1")){
                return "未申请";
            }
            if(invoiceStatus.equals("2")){
                return "待开票";
            }
            if(invoiceStatus.equals("3")){
                return "已开具";
            }
            return "未知发票状态"+invoiceStatus;
        }else {
            return "未知发票状态";
        }
    }


}
